from django.db import models
from django.contrib.auth.models import AbstractUser
from django.utils import timezone


class User(AbstractUser):
    """自定义用户模型类"""
    GENDER_CHOICES = (
        ('1', "男"),
        ('2', "女"))
    gender = models.CharField(max_length=6, choices=GENDER_CHOICES, default="1", verbose_name="性别")
    avatarUrl = models.CharField(max_length=255,
                                 default="http://images.zyntt.cn/timg.png",
                                 verbose_name="头像")
    language = models.CharField(max_length=255,
                                default="zh_CN",
                                verbose_name="语言")
    country = models.CharField(max_length=255,

                               verbose_name="国家")
    city = models.CharField(max_length=255,

                            verbose_name="地区")
    province = models.CharField(max_length=255,

                                verbose_name="城市")
    # mobile = models.CharField(max_length=11, unique=True, verbose_name='手机号')
    utime = models.DateTimeField(verbose_name='创建时间', default=timezone.now)
    open_id = models.CharField(max_length=255, null=True, blank=True, verbose_name="绑定的微信号的open_id")

    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username
